package com.idcf.boathouse.order.controller;

import com.idcf.boathouse.order.core.ResponseData;
import com.idcf.boathouse.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description 订单接口类
 * @author: steve chenwang94@gmail.com
 * @create: 2020-12-29 14:07:25
 **/
@RestController
@RequestMapping(value = "/orders")
public class OrderController {
    @Autowired
    OrderService orderService;

    @RequestMapping(value = "/pending")
    public ResponseData getOrders() {
        return ResponseData.success(orderService.getOrderList());
    }

    @RequestMapping(value = "/confirm")
    public ResponseData confirmOrder(String orderId) {
        orderService.confirmOrder(orderId);
        return ResponseData.success(null);
    }

    @RequestMapping(value = "/refuse")
    public ResponseData refuseOrder(String orderId) {
        orderService.refuseOrder(orderId);
        return ResponseData.success(null);
    }

    @RequestMapping(value = "/deliver")
    public ResponseData deliverOrder(String orderId) {
        orderService.deliverOrder(orderId);
        return ResponseData.success(null);
    }

    @RequestMapping(value = "/purchase")
    public ResponseData purchase(Integer setId, String address) {
        orderService.makeNewOrder(setId, address);
        return ResponseData.success(null);
    }

}
